package com.ybkj.o2o.mc.common.query;

import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * Created by shine on 16/9/19.
 */
public class PassengerQuery implements Serializable {

  private Integer type;

  private Long gradeId;

  private Long companyId;

  private Date startTime;

  private Date endTime;

  private String keyword; //like 查询

  private String appKey;

  private String phone; //like 查询

  private String introducer;

  private Integer introduceType;

  private Boolean inBlackList;

  private Integer page;

  private Integer rows;

  private Integer offset;

  private String channelName;//来源名称

  private Long[] ids;

  public Long[] getIds() {
    return ids;
  }

  public void setIds(Long[] ids) {
    this.ids = ids;
  }

  public Integer getType() {
    return type;
  }

  public void setType(Integer type) {
    this.type = type;
  }

  public Long getGradeId() {
    return gradeId;
  }

  public void setGradeId(Long gradeId) {
    this.gradeId = gradeId;
  }

  public Long getCompanyId() {
    return companyId;
  }

  public void setCompanyId(Long companyId) {
    this.companyId = companyId;
  }

  public Date getStartTime() {
    return startTime;
  }

  /**
   * 把long转换为date类型.
   */
  public void setStartTime(Long start) {
    if (null != start) {
      this.startTime = new Date(start);
    }
  }

  public Date getEndTime() {
    return endTime;
  }

  /**
   * 把long转换为date类型.
   */
  public void setEndTime(Long end) {
    if (null != end) {
      this.endTime = new Date(end);
    }
  }

  public String getKeyword() {
    return keyword;
  }

  /**
   * 普通字符串转换为数据库模糊查询的字符串，即两边连接'%'.
   */
  public void setKeyword(String keyword) {
    if (StringUtils.isNotBlank(keyword)) {
      this.keyword = "%" + keyword + "%";
    } else {
      this.keyword = null;
    }
  }

  public String getAppKey() {
    return appKey;
  }

  public void setAppKey(String appKey) {
    this.appKey = appKey;
  }

  public Boolean isInBlackList() {
    return inBlackList;
  }

  public void setInBlackList(Boolean inBlackList) {
    this.inBlackList = inBlackList;
  }

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getRows() {
    return rows;
  }

  public void setRows(Integer rows) {
    this.rows = rows;
  }

  /**
   * 根据page和rows计算出偏移量.
   */
  public Integer getOffset() {
    if (getPage() == null || getRows() == null) {
      return null;
    }
    if (getPage() > 0) {
      return (getPage() - 1) * getRows();
    }

    return offset;
  }

  public void setOffset(Integer offset) {
    this.offset = offset;
  }

  public String getPhone() {
    return phone;
  }

  public void setPhone(String phone) {
    this.phone = phone;
  }

  public String getIntroducer() {
    return introducer;
  }

  public void setIntroducer(String introducer) {
    this.introducer = introducer;
  }

  public Integer getIntroduceType() {
    return introduceType;
  }

  public void setIntroduceType(Integer introduceType) {
    this.introduceType = introduceType;
  }

  public String getChannelName() {
    return channelName;
  }

  public void setChannelName(String channelName) {
    this.channelName = channelName;
  }
}
